import { lengthUnits, useRightPosition, useUnit } from '@amcax/base';
import { unitManager } from '@app-base/module';
import { Select } from 'antd';

export const UnitSwitch = () => {
  const { lengthUnit } = useUnit();
  const rightPosition = useRightPosition();

  return (
    <Select
      style={{
        width: 100,
        position: 'absolute',
        right: rightPosition + 10,
        top: '200px',
      }}
      options={lengthUnits.map((v) => ({
        label: v.name,
        value: v.name,
      }))}
      value={lengthUnit}
      onChange={(v) => (unitManager.currentLengthUnit = v)}
    />
  );
};
